<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性1——state升级</title>
</head>
<body>
    <!-- 准备一个容器 -->
    <div id="test"></div>

    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>
    <!-- 引入react-dom，支持react操作dom -->
    <script src="../js/react-dom.development.js"></script>
    <!-- 引入babel，将jsx转为js -->
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">/*此处写babel*/ 
        class Weather extends React.Component {
            //初始化状态    类里面可以直接赋值语句
            state = {isHot:false};

            render(){
                const {isHot} = this.state;
                return <h1 onClick={this.changeWether}>今天天气{isHot ? '炎热' : '凉快'}</h1>;
            }
            //自定义方法    用赋值语句+箭头函数形式
            changeWether = () => {
                const isHot = this.state.isHot; 
                this.setState({isHot:!isHot});
            }
        }
        
        ReactDOM.render(<Weather/>,document.getElementById('test'));
        
    </script>
</body>
</html>